package com.abou.model.common;

import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import javax.persistence.Version;

/**
 * The abstract class of all the entity model objects (those that are
 * persisted).
 */
@MappedSuperclass
public class Entity extends AModel {
  
  /**
   *
   */
  private static final long serialVersionUID = 1L;
  
  @Column(name = "OPT_LOCK")
  @Version
  private int version = 0;
  
  /**
   * The empty constructor
   */
  public Entity() {

    super();
  }
  
  /**
   * @return The version used for optimitic locking
   */
  public int getVersion() {

    return version;
  }
  
  /**
   * Sets the new value for the version field.
   * 
   * @param version The new value for the version field
   */
  public void setVersion(int version) {

    this.version = version;
  }
}
